#include <QApplication>
#include <QTranslator>

#include "mainwindow.h"
#include "settings.h"

int main(int argc, char *argv[])
{
    // 启用高DPI放缩
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

    QApplication a(argc, argv);

    // 翻译
    QSettings settings(ORGANIZATION_NAME, APPLICATION_NAME);
    auto language = settings.value(LANGUAGE, ENGLISH).toString();
    if (language == SIMPLIFIED_CHINESE) {
        auto translator = new QTranslator(&a);
        translator->load(":/DigitalMixer_zh_CN.qm");
        a.installTranslator(translator);
    }

    // 设置LOGO
    a.setWindowIcon(QIcon(":/img/logo.png"));

    // 设置全局字体策略
    QFont font = a.font();
    font.setFamily("Arial");
    font.setPointSizeF(9 * QGuiApplication::primaryScreen()->availableSize().width() / DevEnvParam::A_WIDTH);
    a.setFont(font);

    MainWindow windows;
    windows.show();

    return a.exec();
}
